Time Dependent Regular Expression - regexp
A regular expression on the basis of the following operators can be defined in []
. The function TPT.regexp()
returns each interval where the expression is true
. Otherwise, if no interval is found, the function’s result is undefined.
This element is the basis of regular expressions. In the simplest case a time dependent logical expression is specified in brackets.
Optionally the minimum time of the matching intervals can be specified in curly braces. If the operation e
is true
in a given interval but is only true for a time shorter than min, it does not match.
Also a minimum and maximum time can be specified in curly braces. Only intervals of a minimum length will match. If the interval is longer than the maximum specified, it will be set at the maximum.
[timedExpr e]
[timedExpr e]{float min}
[timedExpr e]{float min, float max}
iv = TPT.Boolean() iv = TPT.Boolean() iv = TPT.Boolean() |
[c(t)==X]
used within interval calculation corresponds to one interval, formed by an arbitrary number of many consecutive samples where the condition is fulfilled. The different intervals in the following examples will be referred as i1, i2, i3, i4, etc.
For example: ([c(t) == 1]([c(t) == 2][c(t) == 3])*[c(t) == 4] where:
[c(t) == 1] is i1
[c(t) == 2] is i2
[c(t) == 3] is i3
[c(t) == 4] is i4
The suffix *
helps to define expressions that match arbitrarily often.
This means to match zero or more times (0- to n-times).
iv = TPT.Boolean()
|
The suffix +
helps to define expressions that match at least once but also very often (1 to n times).
This means to match one or more times.
iv = TPT.Boolean()
|
The suffix ?
helps to define expressions that match conditionally: it matches once or not at all. The expression can match also a void interval.
iv = TPT.Boolean()
|
As many regular expressions as desired can be written one after another without an explicit operator. The expressions will be evaluated in order from left to right.
# search each interval where c is first 3 and then 4 |
This operator is used to match either the left or the right expression.
The example matches to intervals where
|
Expressions in parentheses can be explicitly named in order to access the matched expression later on.
In this example cEquals4 is defined as a void variable. After the calculation the part intervals that match # search each interval where c is first 3 and then 4 |
The prefix ^
of a regular expression says that this expression must start at the very beginning of the actual time interval.
iv1 = TPT.Boolean() |
The suffix "$" says that the expression must match until the very end of a time interval.
This expression matches only to intervals where in the actual context iv = TPT.Boolean(); |
We want to check whether during TPT.regexp([light_switch(t) == 2]):
|
We define an interval that starts when a condition is fulfilled for the first time and ends at the end of the test sequence. The example below shows how to find the interval starting where a = TPT.DoubleX()
|